package l2ft.gameserver.model.entity.events.impl.fightclub;

import l2ft.commons.collections.MultiValueSet;
import l2ft.gameserver.model.Creature;
import l2ft.gameserver.model.Player;
import l2ft.gameserver.model.Skill;
import l2ft.gameserver.model.entity.events.fightclubmanager.FightClubPlayer;
import l2ft.gameserver.model.entity.events.impl.AbstractFightClub;

public class TeamVSTeamEvent extends AbstractFightClub
{
	public TeamVSTeamEvent(MultiValueSet<String> set)
	{
		super(set);
	}
	
	@Override
	public void onKilled(Creature actor, Creature victim, Skill skill)
	{
		if(actor != null && actor.isPlayable())
		{
			FightClubPlayer realActor = getFightClubPlayer(actor.getPlayer());
			if(victim.isPlayer())
			{
				realActor.increaseKills(true);
				realActor.getTeam().incScore(1);
				updatePlayerScore(realActor);
				updateScreenScores();
				sendMessageToPlayer(realActor, MESSAGE_TYPES.HERO, "You have killed "+victim.getName());
			}
			else if(victim.isPet())
			{
				
			}
			actor.getPlayer().sendUserInfo();
		}
		
		if(victim.isPlayer())
		{
			FightClubPlayer realVictim = getFightClubPlayer(victim);
			realVictim.increaseDeaths();
			if(actor != null)
				sendMessageToPlayer(realVictim, MESSAGE_TYPES.HERO, "You have been killed by "+actor.getName());
			victim.broadcastCharInfo();
		}
		
		super.onKilled(actor, victim, skill);
	}
	
	@Override
	public String getVisibleTitle(Player player, String currentTitle, boolean toMe)
	{
		FightClubPlayer fPlayer = getFightClubPlayer(player);
		
		if(fPlayer == null)
			return currentTitle;
		
		return "Kills: "+fPlayer.getKills(true)+" Deaths: "+fPlayer.getDeaths();
	}
}
